import { IChannelItem } from "@/types/channel"
import { useEffect, useState } from "react"
import API from '@/api'

export const useAllChannelList = () => {
  const [list, setList] = useState<Array<IChannelItem>>([])

  const getAllList = async () => {
    try {
      const res = await API.channel.getAllList()
      setList(res.data.channels)
    }
    catch (err) {
      console.error(err)
    }
  }

  useEffect(() => {
    getAllList()
  }, [])

  return { allChannelList: list }
}

